package com.hqyj.product.service.impl;

import com.hqyj.product.mapper.ProductInfoMapper;
import com.hqyj.product.model.ProductInfo;
import com.hqyj.product.service.ProductInfoService;
import com.hqyj.repertory.mapper.InRepertoryMapper;
import com.hqyj.repertory.mapper.RepertoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class productInfoServiceImpl implements ProductInfoService {

    @Autowired
    private ProductInfoMapper productInfoMapper;
    @Autowired
    private InRepertoryMapper inRepertoryMapper;
    @Autowired
    protected RepertoryMapper repertoryMapper;

    @Override
    public List<ProductInfo> queryAllProductInfo() {
        return productInfoMapper.queryAllProductInfo();
    }

    @Override
    public int addProductInfoByProductInfo(ProductInfo productInfo) {
        return productInfoMapper.insertSelective(productInfo);
    }

    @Override
    public int deleteProductInfoById(int id) {
        return productInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public ProductInfo queryProductInfoById(int productInfoId) {
        return productInfoMapper.selectByPrimaryKey(productInfoId);
    }

    @Override
    public int updateProductInfoByProductInfo(ProductInfo productInfo) {
        return productInfoMapper.updateByPrimaryKeySelective(productInfo);
    }

    @Override
    public int insertInRepertoryByProductInfo(String productId, String productName, Integer productQuantity, String type) {
        return inRepertoryMapper.insertInRepertoryByProductInfo(productId,productName,productQuantity,type);
    }

    @Override
    public int updateRepertoryByProductInfo(String productName, Integer productQuantity) {
        return repertoryMapper.updateRepertoryByProductInfo(productName,productQuantity);
    }

    @Override
    public void updateStateByProductId(int parseInt) {
        productInfoMapper.updateStateByProductId(parseInt);
    }
}
